package net.huashitong.Project.web;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.Message;
import net.huashitong.Project.entity.MessageList;
import net.huashitong.Project.filter.MessageListFilter;
import net.huashitong.Project.service.MessageListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/messageList")
public class MessageListController extends JsonBaseController {

    @Autowired
    private MessageListService messageListService;
    @Override
    protected String getView(String s) {
        return null;
    }

    @ResponseBody
    @RequestMapping(value = "queryNum",method = RequestMethod.GET)
    public Message getMessageListNum(String userId){
        MessageListFilter mf = new MessageListFilter();
        mf.setUserId(userId);
        mf.setIsRead("0");
        List<MessageList> list = messageListService.queryNoReadMessage(mf);
        int result = list.size();
        return coverMessage("200", "创建成功",result);
    }
}

